import { request } from "@/utils/service"
import type * as Combo from "./types/combo"
import { getToken } from "@/utils/cache/cookies"
/** 增 */
export function createComboDataApi(data: any) {
  return request({
    url: "order/packageMaster/add",
    method: "post",
    data
  })
}

/** 删 */
export function deleteComboDataApi(id: string) {
  return request({
    url: "order/packageMaster/del",
    method: "delete",
    params: {
      id
    }
  })
}

/** 改 */
export function updateComboDataApi(data: any) {
  return request({
    url: "order/packageMaster/update",
    method: "put",
    data
  })
}

/** 查 */
export function getComboDataApi1(params: any) {
  return request<any>({
    url: "order/packageMaster/query",
    method: "get",
    params
  })
}
/**主套餐查询去除message字段 */
export function getComboDataApi2(params: any) {
  return request<any>({
    url: "/order/packageMaster/queryByName",
    method: "get",
    params
  })
}
/**主套餐根据ID查详情*/
export function getComboDataDetailApi(params: any) {
  return request<any>({
    url: "/order/packageMaster/api/queryId",
    method: "get",
    params
  })
}
/**套餐根据ID查详情*/
export function getComboDataDetailApi1(params: any) {
  return request<any>({
    url: "/order/package/api/queryId",
    method: "get",
    params
  })
}

//查询即将下架套餐
export function getWillOffComboDataApi(params: Combo.IGetComboRequestData) {
  return request<Combo.GetComboResponseData>({
    url: "order/packageMaster/queryPageWillOverdue",
    method: "get",
    params
  })
}

/**图片上传 */
export function uploadComboImageList(data: any) {
  return request({
    url: "order/package/upload",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data
  })
}

/** 查询全部分销商*/
export function getUserIdList(params: any) {
  return request({
    url: "/retail/user/queryUserAll",
    method: "get",
    params
  })
}
/** 主套餐上下架 */
export function upOrDownEffect(data: any) {
  return request({
    url: "/order/packageMaster/down",
    method: "put",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data
  })
}
/** 套餐佣金规则相关 */
/** 增 */
export function addRules(data: any) {
  return request({
    url: "/commission/add",
    method: "post",
    data
  })
}

/** 删 */
export function delRules(id: string) {
  return request({
    url: "/commission/del",
    method: "delete",
    params: {
      id
    }
  })
}

/** 改 */
export function editRules(data: any) {
  return request({
    url: "/commission/update",
    method: "put",
    data
  })
}

/** 查 */
export function getRules(params: any) {
  return request<any>({
    url: "/commission/queryByPackageId",
    method: "get",
    params
  })
}
/** 佣金规则变更记录 */
export function getRuleLogs(params: any) {
  return request<any>({
    url: "/commissionLog/query",
    method: "get",
    params
  })
}
//删除
export function delRuleLogs(params: any) {
  return request<any>({
    url: "/commissionLog/del",
    method: "Delete",
    params
  })
}
/** 新增佣金规则变更记录 */
export function addRuleLogs(data: any) {
  return request<any>({
    url: "/commissionLog/add",
    method: "post",
    data
  })
}
/** 新增佣金规则变更记录1 */
export function addRuleLogs1(data: any) {
  return request<any>({
    url: "/commissionLog/addMaster",
    method: "post",
    data
  })
}

/** 任务量变更记录 */
export function getRuleLogRw(params: any) {
  return request<any>({
    url: "/taskLog/query",
    method: "get",
    params
  })
}
/**一键复制套餐 */
export function copyCombo(id: any) {
  return request<any>({
    url: `/order/packageMaster/copyPackageMaster/${id}`,
    method: "get"
  })
}

/**佣金规则未配置数据查询 */
export function getNoYj(params: any) {
  return request<any>({
    url: "/order/package/querySum",
    method: "get",
    params
  })
}
